package com.example.homework.db.daos

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.Query
import androidx.room.Update
import com.example.homework.db.tables.Words
import kotlinx.coroutines.flow.Flow

@Dao
interface WordDao {
    @Query("select * from WORDS order by word desc limit 5")
    fun getLastFive(): Flow<List<Words>>

    @Insert
    suspend fun insert(word: Words)

    @Query("delete from WORDS")
    suspend fun deleteAll()

    @Update
    suspend fun update(word: Words)

    @Query("select * from WORDS where word = :word")
    suspend fun getWord(word: String): Words?
}